package com.example.dinnermanager;

import java.util.List;
import java.util.zip.Inflater;

import com.example.dinnermanager.R.layout;

import android.R.integer;
import android.content.Context;
import android.graphics.Color;
import android.provider.Telephony.Sms.Conversations;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class MyAdapter1 extends BaseAdapter {
	private List<String> typeList = null;
	private LayoutInflater inflater = null;
	Context context;
	int checkedId = -1;

	public MyAdapter1(Context context, List<String> l) {
		super();
		this.context = context;
		this.typeList = l;
		this.inflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return typeList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {

		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = inflater.inflate(R.layout.type_order1, null);
			viewHolder.tv = (TextView) convertView.findViewById(R.id.txt_type);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.tv.setText(typeList.get(position));
		if (checkedId == position) {
			viewHolder.tv.setBackgroundResource(R.drawable.but2);
		}else {
			viewHolder.tv.setBackgroundColor(Color.TRANSPARENT);
		}
		return convertView;

	}

	public void setId(int i) {
		checkedId = i;
	}

	public final class ViewHolder {
		public TextView tv;
	}

}
